<template>
  <transition name='fade'>
    <div class="error-page" :style='style'>
      <div class="error fx-jc-ac fxc">
        <a><i class="icon el-icon-c-tanhao ft40" @click="handleClose"></i></a>
        <h2>{{message}}</h2>
      </div>
      <a class="close-btn">
        <i class="icon el-icon-c-close ft40" @click="handleClose"></i>
      </a>
    </div>
  </transition>
</template>

<script>
export default {
  name: 'Error',
  props: {
    message: {
      type: String,
      required: true,
    },
  },
  computed: {
    style() {
      return {
        position: 'fixed',
        top: '0',
        left: '0',
        width: '100vw',
        height: '100vh',
      };
    },
  },
  methods: {
    handleClose(e) {
      e.preventDefault();
      this.$emit('close');
    },
  },
};
</script>
<style lang="scss" scoped>
.error-page {
  width: 100%;
  height: 100%;
}
.error {
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  color: #fff;
  & > i {
    display: inline-block;
    margin-bottom: 20px;
  }
}
.close-btn {
  display: inline-block;
  position: absolute;
  top: 2vh;
  right: 2vh;
  color: #fff;
}
.fade-enter-active,
.fade-leave-active {
  transition: opacity 3.5s;
}
.fade-enter,
.fade-leave-to {
  opacity: 0;
}
</style>
